/*
 * test_curl.h
 *
 *  Created on: 2014. 7. 2.
 *      Author: jjaehuny
 */

#ifndef TEST_CURL_H_
#define TEST_CURL_H_

#include <gtest/gtest.h>
#include <glog/logging.h>

#include <curl/curl.h>

class test_curl : public testing::Test
{
public:
	class Dummy
	{
	public:
		Dummy() {}
		~Dummy() {}
	};

public:
	// Sets up the test fixture.
	virtual void SetUp() {}

	// Tears down the test fixture.
	virtual void TearDown() {}
};

TEST_F(test_curl, test_curl)
{
	CURL *curl;
	CURLcode res;

	curl = curl_easy_init();
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_URL, "http://naver.com");
		curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
		/* example.com is redirected, so we tell libcurl to follow redirection */
		curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

		/* Perform the request, res will get the return code */
		res = curl_easy_perform(curl);
		/* Check for errors */
		if(res != CURLE_OK)
		{
		  fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
		}

		/* always cleanup */
		curl_easy_cleanup(curl);
	}
}


#endif /* TEST_CURL_H_ */
